﻿using System;
using System.Collections.Generic;

namespace SFJDManagement.SocketHandle
{
    class DictionaryInitialize
    {
        private const int diff = 20000;
        private static Dictionary<int, Type> dictionary = new Dictionary<int, Type>(10);

        public DictionaryInitialize()
        {
            if (dictionary.Count > 0)
            {
                return;
            }
            else
            {
                Initialize();
            }
        }

        private void Initialize()
        {
            AddServer2UIHandle();
        }

        private void AddServer2UIHandle()
        {
            AddDictionary(1, typeof(SC01RegisterDataReply));
            AddDictionary(2, typeof(SC02RegisterBrigade));
            AddDictionary(3, typeof(SC03RegisterContact));
            AddDictionary(4, typeof(SC04RegisterUser));
            AddDictionary(5, typeof(SC01EditData));
            AddDictionary(6, typeof(SC01RemoveLastData));
            AddDictionary(7, typeof(SC02EditBrigade));
            AddDictionary(8, typeof(SC02RemoveBrigade));
            AddDictionary(9, typeof(SC03RemoveContact));
            AddDictionary(10, typeof(SC04EditUser));
            AddDictionary(13, typeof(SC01SynData));
        }

        private void AddDictionary(int number, Type type)
        {
            dictionary.Add(number + diff, type);
        }

        public Dictionary<int, Type> GetDictionary()
        {
            if (dictionary.Count == 0)
            {
                Initialize();
            }
            return dictionary;
        }
    }
}
